// Listing 14.1. If horse could fly...
// Percolating Fly() up into Horse
#include <iostream>
using namespace std;

class Horse {
public:
  void Gallop() { cout << "Galloping...\n"; }
  virtual void Fly() { cout << "Horse can't fly.\n"; }

private:
  int itsAge;
};

class Pegasus : public Horse {
public:
  virtual void Fly() {
    cout << "I can fly! I can fly! I can fly!";
  }
};

const int NumerHorses = 5;
int main(void) {
  Horse* Ranch[NumerHorses];
  Horse* pHorse;
  int choice,i;
  for(i = 0; i < NumerHorses; i++) {
    cout << "(1)Horse (2)Pegasus: ";
    cin >> choice;
    if(choice == 2) {
      pHorse = new Pegasus;  
    } else {
      pHorse = new Horse;
    }
    Ranch[i] = pHorse;
  } 
  cout << endl; 
  for(i = 0; i < NumerHorses; i++) {
    Ranch[i]->Fly();
    delete Ranch[i];
  }
  return 0;
}